﻿cmake_minimum_required(VERSION 3.14)

project(common VERSION 0.1 LANGUAGES CXX)

set(CMAKE_INCLUDE_CURRENT_DIR ON)

set(CMAKE_AUTOUIC ON)
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)

set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD_REQUIRED ON)



find_package(QT NAMES Qt6 Qt5 COMPONENTS Core Quick Qml Concurrent Svg Widgets LinguistTools SerialPort Network REQUIRED)
find_package(Qt${QT_VERSION_MAJOR} COMPONENTS Core Quick Qml Concurrent Svg Widgets LinguistTools SerialPort Network REQUIRED)



add_definitions(-DQT_QUICK_CONTROLS_STYLE)
set(QT_QUICK_CONTROLS_CONF ":/qml/qtquickcontrols2.conf")


# sources
# ******************************************************************************
#message("CMAKE_CURRENT_SOURCE_DIR:sssssssss:" ${CMAKE_CURRENT_SOURCE_DIR})
#message("ROOT_DIR:sssssssss:" ${ROOT_DIR})
#include_directories(${CMAKE_CURRENT_SOURCE_DIR}/src/common)
AddInclude("${CMAKE_CURRENT_SOURCE_DIR}" "Include" list_app_include)
AddSources("${CMAKE_CURRENT_SOURCE_DIR}" "Src" list_app_src)
AddResources("${CMAKE_CURRENT_SOURCE_DIR}/Resources/qml" "Qml" list_qml_src)
AddResourcesQRC("${CMAKE_CURRENT_SOURCE_DIR}" "Resources" list_Resources_src)


message("SB:" +${ROOT_DIR})
# target
# ******************************************************************************
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
set(ALL_SOURCES
    ${list_app_include}
    ${list_app_src}
    ${list_Resources_src}
    ${list_qml_src}
    )


set(FILES_PATH
    ${CMAKE_CURRENT_SOURCE_DIR}/qmlmodules
    )

add_library(${PROJECT_NAME} STATIC
${ALL_SOURCES}
)

target_compile_definitions(${PROJECT_NAME}
  PRIVATE $<$<OR:$<CONFIG:Debug>,$<CONFIG:RelWithDebInfo>>:QT_QML_DEBUG>)

target_include_directories(${PROJECT_NAME}
        PUBLIC
        ${list_app_include}
        )
    
target_link_libraries(${PROJECT_NAME}
  PRIVATE Qt${QT_VERSION_MAJOR}::Core 
  Qt${QT_VERSION_MAJOR}::Widgets
  Qt${QT_VERSION_MAJOR}::Svg
  Qt${QT_VERSION_MAJOR}::Quick 
  Qt${QT_VERSION_MAJOR}::Qml
  Qt${QT_VERSION_MAJOR}::SerialPort
  Qt${QT_VERSION_MAJOR}::Network
  Qt${QT_VERSION_MAJOR}::Concurrent  
  )



set_target_properties(${PROJECT_NAME} PROPERTIES
    MACOSX_BUNDLE_GUI_IDENTIFIER my.example.com
    MACOSX_BUNDLE_BUNDLE_VERSION ${PROJECT_VERSION}
    MACOSX_BUNDLE_SHORT_VERSION_STRING ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}
)

